#include <iostream>

using namespace std;
//设计立方体类(Cube)
//求出立方体的面积和体积
//分别用全局函数和成员函数判断两个立方体是否相等

//立方体类设计
//1、创建立方体类
//2、设计属性
//3、设计行为获取立方体面积和体积
//4、分别利用全局函数和成员函数判断两个立方体是否相等
class Cube {
private:
    int longer;//长
    int wide;//宽
    int high;//高
public:
    void setLonger(int l) {
        this->longer = l;
    }

    int getLonger() {
        return longer;
    }

    void setWide(int w) {
        this->wide = w;
    }

    int getWide() {
        return wide;
    }

    void setHigh(int h) {
        this->high = h;
    }

    int getHigh() {
        return high;
    }

    int Area() {
        return 2 * longer * wide + 2 * longer * high + 2 * wide * high;
    }

    int Volume() {
        return longer * wide * high;
    }

    //利用成员函数判断两个立方体是否相等
    bool SameByClass(Cube &cube) {
        if (this->getLonger() == cube.getLonger() && this->getWide() == cube.getWide() ||
            this->getHigh() == cube.getHigh()) {
            return true;
        } else {
            return false;
        }
    }
};

//利用全局函数判断两个立方体是否相等
bool Same(Cube &cube1, Cube &cube2) {
    if (cube1.getLonger() == cube2.getLonger() && cube1.getWide() == cube2.getWide() ||
        cube1.getHigh() == cube2.getHigh()) {
        return true;
    } else {
        return false;
    }
}

int main() {
    Cube cube1;
    cube1.setHigh(10);
    cube1.setLonger(10);
    cube1.setWide(10);
    cout << "表面积为:" << cube1.Area() << endl;
    cout << "体积为:" << cube1.Volume() << endl;
    Cube cube2;
    cube2.setHigh(10);
    cube2.setLonger(10);
    cube2.setWide(10);
    bool flag = cube1.SameByClass(cube2);
    if (flag) {
        cout << "两个立方体是相等的" << endl;
    } else {
        cout << "两个立方体不是相等的" << endl;
    }
    bool ret = Same(cube1, cube2);
    if (ret) {
        cout << "两个立方体是相等的" << endl;
    } else {
        cout << "两个立方体不是相等的" << endl;
    }
    return 0;
}
